1. Please use the button
.
2. What is in your code 'Bid' and 'Ask'? How do you get these variables? How do you populate these variables?
Vladimir Karputov:
1. Please use the button .
2. What is in your code 'Bid' and 'Ask'? How do you get these variables? How do you populate these variables?
this is my program this one is working but i need to do the other one the one with the stop lose
#include<Trade\Trade.mqh> // Create a trade CTrade trade; void OnTick() { // calculate the ask price double Ask= NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits); // calculate the Bid price double Bid= NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits); // get the acc Balance double Balance=AccountInfoDouble(ACCOUNT_BALANCE); // get the acc Equity double Equity=AccountInfoDouble(ACCOUNT_EQUITY); // create an array for the prices MqlRates Priceinfo[]; // we fill the array with the price data int PriceData =CopyRates(Symbol(),Period(),0,10,Priceinfo); // create a string for the signal string signal=""; // create an array for several prices double myPriceArraySMA[]; double myPriceArrayMacD[]; // define the properties of the moving average int movingAverageDefinition =iMA (_Symbol,_Period,100,0,MODE_SMA,PRICE_CLOSE); // defined Ea one line, current candle, 3 candles , store result CopyBuffer(movingAverageDefinition,0,0,10,myPriceArraySMA); // define the properties of the MacD int MacDDefinition= iMACD(_Symbol,_Period,12,26,9,PRICE_CLOSE); // define MA1, one buffer, current candle, 3 candles, store result CopyBuffer(MacDDefinition,0,0,10,myPriceArrayMacD); // get the value of the current candle double MacDValue=(myPriceArrayMacD[0]); // if the price is above the SMA if (Priceinfo[1].close > myPriceArraySMA[1]) // and was above the SMA before if (Priceinfo[3].close > myPriceArraySMA[3]) if (MacDValue>0.000630) { signal="buy"; } // if the price is below the SMA if (Priceinfo[1].close < myPriceArraySMA[1]) // and was above the SMA before if (Priceinfo[3].close < myPriceArraySMA[3]) if (MacDValue<-0.000630) { signal="sell"; } /*------------------------------------------------------------------------------------------------------- //if no open positions SELL if (PositionsTotal()==0 && OrdersTotal()==0) { trade.SellStop(0.10,Bid-10*_Point,_Symbol,Bid+50*_Point,Bid-150*_Point,ORDER_TIME_GTC,0,NULL); } //if no open positions BUY if (PositionsTotal()==0 && OrdersTotal()==0) { trade.BuyStop(0.10,Ask-10*_Point,_Symbol,Ask+50*_Point,Ask-150*_Point,ORDER_TIME_GTC,0,NULL); } ------------------------------------------------------------------------------------------------------------*/ //---------------------------------------------------------------------------------------------- //sell 10 microlot if (signal =="sell" && PositionsTotal()<1) trade.Sell(0.10,NULL,Bid,0,(Bid-150 * _Point),NULL); //trade.SellLimit(0.10,NULL,_Symbol,50,150,ORDER_TIME_GTC,0,NULL); // buy 10 microlot if (signal =="buy" && PositionsTotal()<1) trade.Buy(0.10,NULL,Ask,0,(Ask+150 * _Point),NULL); //trade.BuyLimit(0.10,NULL,_Symbol,50,150,ORDER_TIME_GTC,0,NULL); //------------------------------------------------------------------------------------------------------- // chart output Comment ("The Signl is now: ",signal); } //+-----------------------------------------------------------------
this is my program this one is working but i need to do the other one the one with the stop lose
The indicator handle needs to be received once in OnInit.
Correct your code. Until correct, I will not look further.
The indicator handle needs to be received once in OnInit.
Correct your code. Until correct, I will not look further.
hello I need help guys the gentleman said that i had to correct my code so he can help me :) help me correct it this is what help means ??!! Thank You.
hello I need help guys the gentleman said that i had to correct my code so he can help me :) help me correct it this is what help means ??!! Thank You.
Correct your code: now you are creating a new indicator handle FOR EVERY TICK - this is wrong, this is a mistake. An indicator handle must be created ONCE (the indicator handle is created in OnInit ()).
hello I need help guys the gentleman said that i had to correct my code so he can help me :) help me correct it this is what help means ??!! Thank You.
He said "The indicator handle needs to be received once in OnInit.", to understand, you can refer to :
https://www.mql5.com/en/docs/indicators/ima and https://www.mql5.com/en/docs/indicators/imacd.
![Documentation on MQL5: Technical Indicators / iMA Documentation on MQL5: Technical Indicators / iMA](https://c.mql5.com/36/33/documentation-on-mql5-technical__2.png)
- www.mql5.com
Hi guys I cant grasp it Im sorry .... I know now what every fn means and the write place for the code but I need more books to fully get it so what books or learning materials do you recommend for me ? Thank You For Your Patience.
One Last thing I learned this code from this youtuber I think he is bad do you recommend him for me ? https://www.youtube.com/channel/UCokIBdJXNOSOeYkKDvENWYA
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi
I need your help i dont know what is wrong with this code it did nothing when i tested in the strategy tester here is the code
------------------------------------------------------------------------------------------------------------------------------------------------
when i run this version its running just fine but i need to add stop lose i dont know how can i fix it please Help!!