Nedal Burdukani:
Good evening
I want a code that returns the last three digits of the euro price, for example, the euro price now: 1.16835
I want to store the last three digits from the right, i.e. (835) in a variable.
MT5
thank you
Where is your attempt?
Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!
This is my attempt, sir void OnTick() { //-------------------START-------------------------------- double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);// double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);// total_deal = PositionsTotal();// total_order = OrdersTotal();// //-------------------------------------------------------- MyLot1 = LOT1;// MyLot2 = LOT2;// MyMasafe = Masafe_Oreder; if(MyLot1 > 0.10) { MyLot1 = 0.10; }//end if if(MyLot2 > 0.20) { MyLot2 = 0.20; }//end if if(MyMasafe > 100 ) {MyMasafe = 100 ;}//end if ************* هام //------------------------- ----------------------- if((GoTrade ==1)&& (total_deal ==0)&& (total_order ==0)){ // double MyLot = (Mybalance * 0.02) / 0.0015 ; // The next line is not executed because the value in the variable is not appropriate Example: (985 * 0.02) / 0.0015 = 13133 which is suitable for the size of a lot (give me a code to solve this problem only and I thank you trade.Buy( MyLot ,NULL,Ask,Ask - (100 * _Point),Ask + (300 * _Point),"test");// BUY MARKET Sleep(500);// ticket_Buy_1 = PositionGetTicket(0); // price_Buy_1 = PositionGetDouble(POSITION_PRICE_OPEN);//PRICE OPEN BUY Sleep(500);// // ORDER trade.BuyLimit(MyLot2,(price_Buy_1 - (MyMasafe * _Point)),NULL,price_Buy_1 - (100 * _Point),price_Buy_1 + (200 * _Point),ORDER_TIME_GTC,0,"test");// Sleep(500); ticket_bUY_2 = OrderGetTicket(0); // lot_bUY_2 = OrderGetDouble(ORDER_VOLUME_CURRENT); // LOT SELL price_bUY_2 = OrderGetDouble(ORDER_PRICE_OPEN); // PRICE OPEN SELL GoTrade = 5;// Sleep(500); // Alert("Test"); tmm_1 = 2;// bool ses_7 = PlaySound("alert2");// }// end if
double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
- You don't need to normalize symbol's bid/ask as it's already in normalized form.
- To get the last digits of a double, multiply it by a power of 10, then use MathMod or modulo operator. E.g. the last 3 of 5 digits is (bid * 10^5) % 10^3. (use MathPow instead of ^ if you code it)
Nedal Burdukani:
Good evening
I want a code that returns the last three digits of the euro price, for example, the euro price now: 1.16835
I want to store the last three digits from the right, i.e. (835) in a variable.
MT5
thank you
quite simple math (not tested):
MqlTick p; SymbolInfoTick(Symbol(),p); int d3 = int(pow(10,_Digits)*p.ask)%1000:
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to store the last three digits from the right, i.e. (835) in a variable.
MT5
thank you