Molanis Mistake Anyone? - page 4

 
WHRoeder:

WRONG Did you even bother to READ the link you posted (https://book.mql4.com/variables/types) it says "Global variables are initialized only once before stating the execution of special functions."

Global and static variable are set when the EA is LOADED not during the deinit/init cycle.

Add a print statement just after the Slippage = Slippage * 10 and run it and change charts or time frames and look in the log if you don't want to believe the documentation of us..

Slippage is extern int which it's value is initialized on every init().

PipMultiplier is Global int, through out Molanis EA this value does not change, so the value of PipMultiplier will not change when changing TF or Symbol or opening EA property.

EA press F7 over and over

extern int Extern=3;

int Intern = 1;
bool Do_Once;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
  Alert ("Extern init = ",Extern);
  Alert ("Intern init = ",Intern);
  Do_Once = False;
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit(){return(0);}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   
   if (Do_Once == false)
      {
      Do_Once = true;
      Extern = Extern*2;
      Intern = Intern*2;
      Alert ("Extern start = ",Extern);
      Alert ("Intern start = ",Intern);
      }
   
   return(0);
  }
//+------------------------------------------------------------------+
 
onewithzachy:

Slippage is extern int which it's value is initialized on every init().

PipMultiplier is Global int, through out Molanis EA this value does not change, so the value of PipMultiplier will not change when changing TF or Symbol or opening EA property.

EA press F7 over and over


Does your EA demonstrate the code works as intended? If I follow you correctly, Slippage reverts to my input on upon every init(). PipMultiplier = 1 in globals, but within init() if FiveDigits = true then PipMultiplier = 10... upon every init(). Given Slippage = 3 and FiveDigits = true, PipMultiplier always equals 10? 30 points, 30 points, 30 points?
 
RJo:

Does your EA demonstrate the code works as intended? If I follow you correctly, Slippage reverts to my input on upon every init(). PipMultiplier = 1 in globals, but within init() if FiveDigits = true then PipMultiplier = 10... upon every init(). Given Slippage = 3 and FiveDigits = true, PipMultiplier always equals 10? 30 points, 30 points, 30 points?

In Molanis code, the value of PipMultiplier is remain the same, it never change, whether its five digits or not - don't worry about it. I think what you need to know is the value of Slippage - and I did check it before my reply to WHRoeder - it does not change.

Modify this on init(), attach the Molanis EA, press F7 as many as you like and the value of Slippage remain the same.

   //if(FiveDigits)
   //  {
      PipMultiplier=10;
   //  }
   Slippage=Slippage*PipMultiplier;
   Alert ("Slippage ",Slippage);

:D

 
onewithzachy:

In Molanis code, the value of PipMultiplier is remain the same, it never change, whether its five digits or not - don't worry about it. I think what you need to know is the value of Slippage - and I did check it before my reply to WHRoeder - it does not change.

Modify this on init(), attach the Molanis EA, press F7 as many as you like and the value of Slippage remain the same.

:D


Thank you, onewithzachy, for ending my wild goose chase.
 

Hello.. some help I want to build an EA of double cross moving average for MT4 ECN account

first MA period 14 shift -7

2nd MA period 14 shift -11

buy and sell and close every cross of moving average.

i read many instruction online im still confuse of building my own ea with complete setting and successful function of buy/sell and closing too.

i ask for help to those professional already how can i set the right setting of this EA.

any one can help the step by step.. I will be thankful.