I've managed to sort it. Used a condition block instead of a flags block. Im guessing the flags block just checks flags that are set by a set block.
Best posts made by machTucker
-
RE: Logic (true-false) block not behaving as I expectedposted in Questions & Answers
-
RE: Problem generating Oninit code?posted in Questions & Answers
@jstap Ahhh....got it! Thanks jstap
I'm considering buying your book. Do you have a pdf copy that I'd be able to read on a ipad?
Latest posts made by machTucker
-
RE: Problem generating Oninit code?posted in Questions & Answers
It's annoying. When accessing deals and writing to csv I only seem to get DEAL_ENTRY_OUT deals when using the custom mql block in onTrade(). When I manually put the code into ontradeTransaction() it works fine. This is after making sure I use HistorySelect first.
FYI that code was generated by chatGPT.
-
RE: Problem generating Oninit code?posted in Questions & Answers
Thanks @jstap . I have managed to get it to work by manually adding some code to the OnTradeTransaction() event function after fxdreema has generated its code. Is there a way of specifying the OnTradeTransaction function from fxdreema?/ I thought maybe it would be possible using a custom function but I'm not familiar with that part of fxdreema yet.
-
RE: Problem generating Oninit code?posted in Questions & Answers
Thanks for the help everyone. I'm using the custom mql code block as I can code a little. I'm trying to output all deals (ENTRY_IN and ENTRY_OUT) and eventually I will be logging the indicator values at time of entry and exit.
At the moment it is only logging DEAL_ENTRY_OUT deals. Can anyone see what I'm doing wrong? The code is a follows and under On trade.
//=========================================== // FXDreema On Trade Custom Block Logger //=========================================== // static variable to track last logged deal static ulong last_logged_deal = 0; // get total number of deals int total_deals = HistoryDealsTotal(); if(total_deals <= 0) return; // get the latest deal ticket ulong deal_ticket = HistoryDealGetTicket(total_deals - 1); if(deal_ticket == 0) return; // avoid logging the same deal twice if(deal_ticket == last_logged_deal) return; last_logged_deal = deal_ticket; // select the deal if(!HistoryDealSelect(deal_ticket)) return; //------------------------------------------- // get deal info //------------------------------------------- ulong deal_order = HistoryDealGetInteger(deal_ticket, DEAL_ORDER); ulong position_id = HistoryDealGetInteger(deal_ticket, DEAL_POSITION_ID); string symbol = HistoryDealGetString(deal_ticket, DEAL_SYMBOL); long deal_type_i = HistoryDealGetInteger(deal_ticket, DEAL_TYPE); long deal_entry_i = HistoryDealGetInteger(deal_ticket, DEAL_ENTRY); long deal_reason_i = HistoryDealGetInteger(deal_ticket, DEAL_REASON); datetime deal_time = (datetime)HistoryDealGetInteger(deal_ticket, DEAL_TIME); double volume = HistoryDealGetDouble(deal_ticket, DEAL_VOLUME); double profit = HistoryDealGetDouble(deal_ticket, DEAL_PROFIT); double price = HistoryDealGetDouble(deal_ticket, DEAL_PRICE); double swap = HistoryDealGetDouble(deal_ticket, DEAL_SWAP); double commission = HistoryDealGetDouble(deal_ticket, DEAL_COMMISSION); long magic = HistoryDealGetInteger(deal_ticket, DEAL_MAGIC); string comment = HistoryDealGetString(deal_ticket, DEAL_COMMENT); //------------------------------------------- // get current market prices //------------------------------------------- double bid = SymbolInfoDouble(symbol, SYMBOL_BID); double ask = SymbolInfoDouble(symbol, SYMBOL_ASK); double spread = ask - bid; //------------------------------------------- // convert enums to readable strings //------------------------------------------- string deal_type = ""; switch(deal_type_i) { case DEAL_TYPE_BUY: deal_type="DEAL_TYPE_BUY"; break; case DEAL_TYPE_SELL: deal_type="DEAL_TYPE_SELL"; break; case DEAL_TYPE_BALANCE: deal_type="DEAL_TYPE_BALANCE"; break; case DEAL_TYPE_CREDIT: deal_type="DEAL_TYPE_CREDIT"; break; default: deal_type="OTHER"; } string deal_entry = ""; switch(deal_entry_i) { case DEAL_ENTRY_IN: deal_entry="DEAL_ENTRY_IN"; break; case DEAL_ENTRY_OUT: deal_entry="DEAL_ENTRY_OUT"; break; case DEAL_ENTRY_INOUT: deal_entry="DEAL_ENTRY_INOUT"; break; default: deal_entry="OTHER"; } string deal_reason = ""; switch(deal_reason_i) { case DEAL_REASON_EXPERT: deal_reason="DEAL_REASON_EXPERT"; break; case DEAL_REASON_SL: deal_reason="DEAL_REASON_SL"; break; case DEAL_REASON_TP: deal_reason="DEAL_REASON_TP"; break; case DEAL_REASON_SO: deal_reason="DEAL_REASON_SO"; break; case DEAL_REASON_CLIENT: deal_reason="DEAL_REASON_CLIENT"; break; default: deal_reason=IntegerToString(deal_reason_i); } //------------------------------------------- // write to CSV //------------------------------------------- int file = FileOpen("MyStrategy.csv", FILE_READ|FILE_WRITE|FILE_CSV|FILE_SHARE_WRITE|FILE_COMMON, ","); if(file != INVALID_HANDLE) { FileSeek(file,0,SEEK_END); FileWrite(file, deal_ticket, deal_order, position_id, symbol, deal_type, deal_entry, deal_reason, TimeToString(deal_time,TIME_DATE|TIME_SECONDS), DoubleToString(volume,2), DoubleToString(profit,2), DoubleToString(price,_Digits), DoubleToString(swap,2), DoubleToString(commission,2), magic, comment, DoubleToString(bid,_Digits), DoubleToString(ask,_Digits), DoubleToString(spread,_Digits) ); FileClose(file); } -
RE: Problem generating Oninit code?posted in Questions & Answers
@jstap Ahhh....got it! Thanks jstap
I'm considering buying your book. Do you have a pdf copy that I'd be able to read on a ipad?
-
Problem generating Oninit code?posted in Questions & Answers
Hi everyone,
I'm trying to create a csv file in OnInit() and not having much luck. It's a basic as it gets atm but it doesn't seem to be generating the code in the mq5 file. Any ideas?
-
RE: Logic (true-false) block not behaving as I expectedposted in Questions & Answers
I've managed to sort it. Used a condition block instead of a flags block. Im guessing the flags block just checks flags that are set by a set block.
-
RE: Logic (true-false) block not behaving as I expectedposted in Questions & Answers
@jstap Hmm, OK. I set up a constant called use_regime as an input variable. I intended for the user to be able to set either true or false before running the EA. I'm guessing I haven't done that correctly? I selected the constant in the logic block, what am I doing wrong?
-
Logic (true-false) block not behaving as I expectedposted in Questions & Answers
Hi everyone,
https://fxdreema.com/shared/P2p5QJbD
Newbie to fxdreema here. Getting to grips with the blocks etc and trying to build and replicate some existing strategies I have coded myself.
I was trying to implement a custom indicator and in doing so used a logic block. Very simple test....if true then use custom indicator and buy, if false sell.
When I run it it sells all the time regardless of how the flag is set. What am I doing wrong?
E