[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 973

 
gheka:

extern int Period_MA = 21;

bool Fact_Up = true;

bool Fact_Dn = true;

int start()

{
double MA;

MA=iMA(NULL,0,Period_MA,0,MODE_SMA,PRICE_CLOSE,0);
if (Bid > MA && Fact_Up == true)

{
Fact_Dn = true;

Fact_Up = false;

Alert("Price is above MA(",Period_MA,").");
}
if (Bid < MA && Fact_Dn == true )
{
Fact_Up = true;
Fact_Dn = false;
Alert("Price is below MA(",Period_MA,").");

}
return;
}

Anyway, it's from the textbook, I wanted to practice, but I got a deadlock, after crossing

I want to give it a report once. How do I get it to report on every tick?

help?


The question is not quite rightly posed
 
Vinin:

The question is not quite right


it only triggers a message once only after the crossing,

How can I get a message after every tick,

so that on every tick there is a message like "price is above the mach" or "price is below the mach"?

 

Hello, I wanted to make a filter so that a given number of buy/sell signals issued by the indicator would be skipped. I tried to implement it with global variables to fix the number of signals received and compare it with a given variable. It works, but in global variables the number of signals is not increasing. What is the error? Or there is a simpler way to implement the idea?

Can you please tell me....

//--------------
    if(SignalBuy>0) { 
   int B;
     if(SignalBuy==true){
       B=1;
       } else {
       B=0;
       }
       int PropuskSigB=GlobalVariableGet("PropuskSignalaB");
            PropuskSignalaB =B+PropuskSigB;
            GlobalVariableSet(gvp+"PropuskSignalaB",PropuskSignalaB);
          PropuskSignalaB=GlobalVariableGet("PropuskSignalaB");
       Print ("PropuskSignalaB = ",PropuskSignalaB);
      }
   //-------------   
    if(SignalSell>0){
   int S;
     if(SignalSell==true){
       S=1;
       } else {
       S=0;
       }
       int PropuskSigS=GlobalVariableGet("PropuskSignalaS");
            PropuskSignalaS =S+PropuskSigS;
            GlobalVariableSet(gvp+"PropuskSignalaS",PropuskSignalaS);
          PropuskSignalaB=GlobalVariableGet("PropuskSignalaS");
       Print ("PropuskSignalaS = ",PropuskSignalaS);
    }
   //-------------
 

How do I normalise the lot to one decimal place? eg lot 1.43 or 1.438 to 1.4 or 1.5 ? otherwise it gives error 131 - incorrect lot size?

 
In Metaeditor search - under the Navigator tab - type in the word Normalisation and you're good to go :)
 
Rossi:

How do I normalise my lot to one decimal place? e.g. lot 1.43 or 1.438 to 1.4 or 1.5 ? otherwise it gives error 131 - wrong lot size?


Here's a whole lot normalization feature, like in my EA... In the editor, press F1 on NormalizeDouble() - in the Help

...and it's all explained in details...

double NormalizeLots(double lot)
{
   double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
   double lots = NormalizeDouble(lot / lotStep, 0) * lotStep;   
   lots = MathMax(lots, MarketInfo(Symbol(), MODE_MINLOT));
   lots = MathMin(lots, MarketInfo(Symbol(), MODE_MAXLOT));   
   return (lots);
}
 

Thanks. but double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
can't we just do double lotStep = 0.1;?

 
Rossi:

Thank you. And double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
can't we just do double lotStep = 0.1;?


Lotstep is usually 0.01 - it depends on both the broker and the account type, read the trading conditions for your account type -

if there is a 0.1 lotstep, then you can... This is an option for any type of account, so you don't have to worry about it...

 
How do I calculate the profit as a percentage of the balance of only certain positions with the same magician?
 

Man, does anyone know the answer to my question?

Tell me about the program TakeMySpread to change the spread. It allows you to change the spread on the symbol to test and optimize. Is there a program that changes the level of stop loss or freeze frame? Or how do I do it manually?
Reason: