Hello i have some problem in my epert advisor can sombodey help me please?

 
int SmallSMA=9;
  int BigSMA=17;
  int OrderNumber=0;
 void OnTick ()
{
 string signal ="";
 double SmallMovingAverage1 =iMA(_Symbol, PERIOD_H1, SmallSMA, 0, MODE_SMA, PRICE_CLOSE, 1);  
 double BigMovingAverage2 =iMA(_Symbol, PERIOD_H1, BigSMA, 0, MODE_SMA, PRICE_CLOSE, 1); 
 double SmallMovingAverage2 =iMA(_Symbol, PERIOD_H1, SmallSMA, 0, MODE_SMA, PRICE_CLOSE, 2); 
 double BigMovingAverage1 =iMA(_Symbol, PERIOD_H1, BigSMA, 0, MODE_SMA, PRICE_CLOSE, 2); 
 
 {
 if (BigMovingAverage1 > SmallMovingAverage1)
 if(BigMovingAverage2 < SmallMovingAverage2)
 signal="sell";
 }
{
if (BigMovingAverage1 < SmallMovingAverage1)
if(BigMovingAverage2 > SmallMovingAverage2)
signal="buy";
}
{
 Alert ("OrdersTotal is "+OrdersTotal); 
 if (signal=="buy" && OrdersTotal ()==0)
 OrderNumber = OrderSend (_Symbol,OP_BUY, 0.10,Ask,3,0, Ask+150*_Point, NULL, 0,0, Green);
 if (signal=="sell" && OrdersTotal () ==0) 
 OrderNumber = OrderSend (_Symbol,OP_SELL, 0.10,Ask,3,0, Ask-150*_Point, NULL, 0,0, Red);
 Comment ("The current signal is:",signal);
 Alert (OrderNumber);
 }
}
 
ניר לוי: Hello i have some problem in my epert advisor can sombodey help me please?
  1. You have "some problem?" Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

    How can we know what it's doing and what you want it to do?

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  3. OrderNumber = OrderSend (_Symbol,OP_BUY, 0.10,Ask,3,0, Ask+150*_Point, NULL, 0,0, Green);
    OrderNumber = OrderSend (_Symbol,OP_SELL, 0.10,Ask,3,0, Ask-150*_Point, NULL, 0,0, Red); 

    You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.

    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
      Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).

    1. Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk. Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

      1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.

      2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)

      3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                  MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum 2017.10.10
                  Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
                  Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19

      4. You must normalize lots properly and check against min and max.

      5. You must also check FreeMargin to avoid stop out

      Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.


 
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code properly in a new post.

Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
Reason: