Posts

MQL5 Multi currency big boss big candle ea

 //+------------------------------------------------------------------+ //|                             BigBossCandleAtrCalMulticurrency.mq5 | //|                                  Copyright 2023, MetaQuotes Ltd. | //|                                             https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2023, MetaQuotes Ltd." #property link      "https://www.mql5.com" #property version   "1.00" double ATR[]; #include <Trade\Trade.mqh> CTrade trade; datetime ExitTime; enum stmode   {    BUY=1,    SELL=2,    BOTH=3,   }; string stgmodes; input ENUM_TIMEFRAMES Time...

MQL5 : Add time to current time in mins

 datetime currentTime = TimeCurrent();  // Get the current time int minutesToAdd = 30;  // Example: Add 30 minutes // Add minutes to current time (converted to seconds) datetime newTime = currentTime + minutesToAdd * 60; // Output the new time Print("Current Time: ", TimeToString(currentTime, TIME_DATE | TIME_MINUTES)); Print("New Time: ", TimeToString(newTime, TIME_DATE | TIME_MINUTES));

MQL5 : Get running pnl

 mtm=AccountInfoDouble(ACCOUNT_PROFIT);   Get running pnl  by magin number for specific chart double GetPnLByMagicNumber(int magic_number)   {    double total_pnl = 0.0;    for(int i = 0; i < PositionsTotal(); i++)      {       ulong ticket = PositionGetTicket(i);       int position_magic = (int)PositionGetInteger(POSITION_MAGIC);       if(position_magic == magic_number)         {          total_pnl += PositionGetDouble(POSITION_PROFIT);         }      }    return total_pnl;   }

MQL5 : Calculate total pnl of today closed trades

 double Today_Closed_Profit()  {     MqlDateTime SDateTime;    TimeToStruct(TimeCurrent(),SDateTime);    SDateTime.hour=0;    SDateTime.min=0;    SDateTime.sec=0;    datetime  from_date=StructToTime(SDateTime);     // From date    SDateTime.hour=23;    SDateTime.min=59;    SDateTime.sec=59;    datetime  to_date=StructToTime(SDateTime);     // To date    to_date+=60*60*24;    HistorySelect(from_date,to_date);    int trades_of_day=0;    double wining_trade=0.0;    double losing_trade=0.0;    double total_profit=0.0;    uint total=HistoryDealsTotal();    ulong    ticket=0; //--- for all deals    for(uint i=0; i<total; i++)      {       //--- try to get deals ticket       if((ticket=HistoryDea...

Python Date and time based entry each symbol seperate

  EntryTime = params [ 'EntryTime' ] EntryTime = datetime.strptime( EntryTime , "%H:%M" ).time() EntryDate = params [ 'EntryDate' ] EntryDate = datetime.strptime( EntryDate , "%d-%b-%y" ) current_date = datetime.now().date() current_time = datetime.now().time() if current_date == EntryDate .date() and current_time .strftime( "%H:%M" ) == EntryTime .strftime( "%H:%M" ) \ and params [ 'InitialTrade' ] is None :

Python strike selection based on premium

  def finc_closest_Ce ( price_dict , target_premium ): closest_ce_symbol = None closest_ce_premium = float ( '-inf' ) for price in price_dict : ce_premium = price_dict [ price ][ "CEPREMIUM" ] if ce_premium < target_premium and ce_premium > closest_ce_premium : closest_ce_premium = ce_premium closest_ce_symbol = price_dict [ price ][ "CESymbol" ] return closest_ce_symbol def generatepricedictce_buy ( price , step , distance , BaseSymbol , formatted_date ): start_price = price end_price = price + ( step * distance ) price_list = [ start_price + i * distance for i in range (( end_price - start_price ) // distance + 1 )] print ( "price_list: " , price_list ) price_dict = { price : { "CESymbol" : f" { BaseSymbol }{ formatted_date }{ price } CE" , "CEPREMIUM" : "PRE" } for price in price_list } for price in price_dict : c...

Python stock devloper multiclient integration (login order placement )

client_dict={} def get_client_detail (): global client_dict try : csv_path = 'clientdetails.csv' df = pd.read_csv( csv_path ) df .columns = df .columns.str.strip() for index , row in df .iterrows(): # Create a nested dictionary for each symbol symbol_dict = { 'Title' : row [ 'Title' ] , 'Value' : row [ 'Value' ] , 'QtyMultiplier' : row [ 'QtyMultiplier' ] , 'autotrader' : None , } client_dict[ row [ 'Title' ]] = symbol_dict # print("client_dict: ", client_dict) except Exception as e : print ( "Error happened in fetching symbol" , str ( e )) get_client_detail()   def stock_dev_login_multiclient ( client_dict ): for value , daram in client_dict .items(): Title = daram [ 'Title' ] if isinstance ( Title...