New to programming - page 2

[Deleted]  
ukt:

I am making the assumption that an EA will work on any time frame that it is attached to and read the signals from the time frame of the chart that the chart is set at. I have seen some EA's that tell it to only read from certain time frames but I think this assumption is correct. I have been wrong about so much I thought I might put my thoughts down to get confirmation or correction.

correct. EA defaults to the environment of the chart it is run on.

yes. An EA can be selective in what time frame, symbol, clock time,etc. it will look for trades... Totally under programmers control.

When you have spare moment please help me to help you... thanks!

HOWTO -- Insert Formatted MQL4 Code Into Your Forum Posts -- Increase YOUR chances for getting replies!

I still am not sure how to insert formatted code. I found the src button but how do paste and copy my code so that it is formatted?

[Deleted]  
ukt:

I am making the assumption that an EA will work on any time frame that it is attached to and read the signals from the time frame of the chart that the chart is set at. I have seen some EA's that tell it to only read from certain time frames but I think this assumption is correct. I have been wrong about so much I thought I might put my thoughts down to get confirmation or correction.

correct. EA defaults to the environment of the chart it is run on.

yes. An EA can be selective in what time frame, symbol, clock time,etc. it will look for trades... Totally under programmers control.

When you have spare moment please help me to help you... thanks!

HOWTO -- Insert Formatted MQL4 Code Into Your Forum Posts -- Increase YOUR chances for getting replies!

I do not know what formatted mql4 code is. How do I make sure it is fromatted?

[Deleted]  
program_ideas:
ukt:

I am making the assumption that an EA will work on any time frame that it is attached to and read the signals from the time frame of the chart that the chart is set at. I have seen some EA's that tell it to only read from certain time frames but I think this assumption is correct. I have been wrong about so much I thought I might put my thoughts down to get confirmation or correction.

correct. EA defaults to the environment of the chart it is run on.

yes. An EA can be selective in what time frame, symbol, clock time,etc. it will look for trades... Totally under programmers control.

When you have spare moment please help me to help you... thanks!

HOWTO -- Insert Formatted MQL4 Code Into Your Forum Posts -- Increase YOUR chances for getting replies!

I do not know what formatted mql4 code is. How do I make sure it is fromatted?

I guess I do not know what formatted code is. Or how to make sure when I copy it is formatted. I would like to do this so that I can receive help.

[Deleted]  
program_ideas:
program_ideas:
ukt:

I am making the assumption that an EA will work on any time frame that it is attached to and read the signals from the time frame of the chart that the chart is set at. I have seen some EA's that tell it to only read from certain time frames but I think this assumption is correct. I have been wrong about so much I thought I might put my thoughts down to get confirmation or correction.

correct. EA defaults to the environment of the chart it is run on.

yes. An EA can be selective in what time frame, symbol, clock time,etc. it will look for trades... Totally under programmers control.

When you have spare moment please help me to help you... thanks!

HOWTO -- Insert Formatted MQL4 Code Into Your Forum Posts -- Increase YOUR chances for getting replies!

I do not know what formatted mql4 code is. How do I make sure it is fromatted?

I guess I do not know what formatted code is. Or how to make sure when I copy it is formatted. I would like to do this so that I can receive help.

I tried to put it in the way the insert formatted MQL4 Code said to but the file was too long.

double Gann = iCustom(NULL, 0, "###Gann_HiLo_Activator_v2###", True, 0, Current + 0);
double Gann1 = iCustom(NULL, 0, "###Gann_HiLo_Activator_v2###", True, 0, Current + 1);


double FastMain = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Strong Trend Line *** *** Indicator Settings ***", True, 2, Current + 0);
double FastSignal = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Weak Trend Line *** *** Indicator Settings ***", True, 3, Current + 0);

double FastMain1 = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Strong Trend Line *** *** Indicator Settings ***", True, 2, Current + 1);
double FastSignal1 = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Weak Trend Line *** *** Indicator Settings ***", True, 3, Current + 1);  
   
   
   //+------------------------------------------------------------------+
   //| Variable End                                                     |
   //+------------------------------------------------------------------+

   //Check position
bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
            //Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Buy)                                           |
            //+------------------------------------------------------------------+

if (PRICE_OPEN < Gann) Order = SIGNAL_CLOSEBUY;
if (FastMain < FastSignal)Order = SIGNAL_CLOSESELL;

            //+------------------------------------------------------------------+
            //| Signal End(Exit Buy)                                             |
            //+------------------------------------------------------------------+

            if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
               if (!EachTickMode) BarCount = Bars;
               IsTrade = False;
               continue;
            }
            //MoveOnce
            if(MoveStopOnce && MoveStopWhenPrice > 0) {
               if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) {
                  if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) {
                  OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
The whole program was too long so this portion should show what I tried to do but it does not work.
[Deleted]  
program_ideas:
program_ideas:
ukt:

I am making the assumption that an EA will work on any time frame that it is attached to and read the signals from the time frame of the chart that the chart is set at. I have seen some EA's that tell it to only read from certain time frames but I think this assumption is correct. I have been wrong about so much I thought I might put my thoughts down to get confirmation or correction.

correct. EA defaults to the environment of the chart it is run on.

yes. An EA can be selective in what time frame, symbol, clock time,etc. it will look for trades... Totally under programmers control.

When you have spare moment please help me to help you... thanks!

HOWTO -- Insert Formatted MQL4 Code Into Your Forum Posts -- Increase YOUR chances for getting replies!

I do not know what formatted mql4 code is. How do I make sure it is fromatted?

I guess I do not know what formatted code is. Or how to make sure when I copy it is formatted. I would like to do this so that I can receive help.

I tried to put it in the way the insert formatted MQL4 Code said to but the file was too long.

double Gann = iCustom(NULL, 0, "###Gann_HiLo_Activator_v2###", True, 0, Current + 0);
double Gann1 = iCustom(NULL, 0, "###Gann_HiLo_Activator_v2###", True, 0, Current + 1);


double FastMain = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Strong Trend Line *** *** Indicator Settings ***", True, 2, Current + 0);
double FastSignal = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Weak Trend Line *** *** Indicator Settings ***", True, 3, Current + 0);

double FastMain1 = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Strong Trend Line *** *** Indicator Settings ***", True, 2, Current + 1);
double FastSignal1 = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Weak Trend Line *** *** Indicator Settings ***", True, 3, Current + 1);  
   
   
   //+------------------------------------------------------------------+
   //| Variable End                                                     |
   //+------------------------------------------------------------------+

   //Check position
bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
            //Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Buy)                                           |
            //+------------------------------------------------------------------+

if (PRICE_OPEN < Gann) Order = SIGNAL_CLOSEBUY;
if (FastMain < FastSignal)Order = SIGNAL_CLOSESELL;

            //+------------------------------------------------------------------+
            //| Signal End(Exit Buy)                                             |
            //+------------------------------------------------------------------+

            if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
               if (!EachTickMode) BarCount = Bars;
               IsTrade = False;
               continue;
            }
            //MoveOnce
            if(MoveStopOnce && MoveStopWhenPrice > 0) {
               if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) {
                  if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) {
                  OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
The whole program was too long so this portion should show what I tried to do but it does not work.
[Deleted]  
program_ideas:
program_ideas:
program_ideas:
ukt:

I am making the assumption that an EA will work on any time frame that it is attached to and read the signals from the time frame of the chart that the chart is set at. I have seen some EA's that tell it to only read from certain time frames but I think this assumption is correct. I have been wrong about so much I thought I might put my thoughts down to get confirmation or correction.

correct. EA defaults to the environment of the chart it is run on.

yes. An EA can be selective in what time frame, symbol, clock time,etc. it will look for trades... Totally under programmers control.

When you have spare moment please help me to help you... thanks!

HOWTO -- Insert Formatted MQL4 Code Into Your Forum Posts -- Increase YOUR chances for getting replies!

I do not know what formatted mql4 code is. How do I make sure it is fromatted?

I guess I do not know what formatted code is. Or how to make sure when I copy it is formatted. I would like to do this so that I can receive help.

I tried to put it in the way the insert formatted MQL4 Code said to but the file was too long.

double Gann = iCustom(NULL, 0, "###Gann_HiLo_Activator_v2###", True, 0, Current + 0);
double Gann1 = iCustom(NULL, 0, "###Gann_HiLo_Activator_v2###", True, 0, Current + 1);


double FastMain = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Strong Trend Line *** *** Indicator Settings ***", True, 2, Current + 0);
double FastSignal = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Weak Trend Line *** *** Indicator Settings ***", True, 3, Current + 0);

double FastMain1 = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Strong Trend Line *** *** Indicator Settings ***", True, 2, Current + 1);
double FastSignal1 = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Weak Trend Line *** *** Indicator Settings ***", True, 3, Current + 1);  
   
   
   //+------------------------------------------------------------------+
   //| Variable End                                                     |
   //+------------------------------------------------------------------+

   //Check position
bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
            //Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Buy)                                           |
            //+------------------------------------------------------------------+

if (PRICE_OPEN < Gann) Order = SIGNAL_CLOSEBUY;
if (FastMain < FastSignal)Order = SIGNAL_CLOSESELL;

            //+------------------------------------------------------------------+
            //| Signal End(Exit Buy)                                             |
            //+------------------------------------------------------------------+

            if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
               if (!EachTickMode) BarCount = Bars;
               IsTrade = False;
               continue;
            }
            //MoveOnce
            if(MoveStopOnce && MoveStopWhenPrice > 0) {
               if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) {
                  if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) {
                  OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
The whole program was too long so this portion should show what I tried to do but it does not work.

This is what I used for my entry. Since I have to do it in pieces. I have no compiling errors but my entry and exit are not what I am trying to accomplish.

   //+------------------------------------------------------------------+
   //| Signal Begin(Entry)                                              |
   //+------------------------------------------------------------------+
   
if ((PRICE_OPEN > Gann)&& (FastMain > FastSignal)) Order = SIGNAL_BUY;
if ((PRICE_OPEN < Gann)&& (FastMain < FastSignal)) Order = SIGNAL_SELL;

   //+------------------------------------------------------------------+
   //| Signal End                                                       |
   //+------------------------------------------------------------------+

   //Buy
   if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
      if(!IsTrade) {
         //Check free margin
         if (AccountFreeMargin() < (1000 * Lots)) {
            Print("We have no money. Free Margin = ", AccountFreeMargin());
            return(0);
         }

         if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
         if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

         Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
         if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
                Print("BUY order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
            } else {
                Print("Error opening BUY order : ", GetLastError());
            }
         }
         if (EachTickMode) TickCheck = True;
         if (!EachTickMode) BarCount = Bars;
         return(0);
      }
   }
ukt
473
ukt  

this can be confusing especially when add in all the associated text too!

so ok, how about this ?

1. no need to always use reply link because the posts get massive, yes? instead just start entering your reply into form at page end. The reader can always scroll back to see other bits of posts that interest them, thanks!

2. since you met source code size limit on SRC form, why not use Attach file: at bottom left of this reply form - click the Browse... button, a File Explorer type popup appears with title bar "Choose file". Navigate to the folder containing the file > select it > and click Open button - anyone wanting to see file just clicks this "message attachment" and can view as a windows temporary file it in MetaEditor... and if want to save the file can do that instead of viewing - then open the file in MetaEditor.

regarding you questions:

sorry friend but my brain's gone to mush... as above posts not make sense to me.

please just attach the file > add comment blocks /*...*/ to the code areas explaining your issues etc. that way is easier to understand what you have concerns about.

I am being a pain maybe, but just cannot 'get it' via your previous posts.

or

maybe some other more knowledgeable reader can offer help here??

[Deleted]  
program_ideas:
program_ideas:
program_ideas:
program_ideas:
ukt:

I am making the assumption that an EA will work on any time frame that it is attached to and read the signals from the time frame of the chart that the chart is set at. I have seen some EA's that tell it to only read from certain time frames but I think this assumption is correct. I have been wrong about so much I thought I might put my thoughts down to get confirmation or correction.

correct. EA defaults to the environment of the chart it is run on.

yes. An EA can be selective in what time frame, symbol, clock time,etc. it will look for trades... Totally under programmers control.

When you have spare moment please help me to help you... thanks!

HOWTO -- Insert Formatted MQL4 Code Into Your Forum Posts -- Increase YOUR chances for getting replies!

I do not know what formatted mql4 code is. How do I make sure it is fromatted?

I guess I do not know what formatted code is. Or how to make sure when I copy it is formatted. I would like to do this so that I can receive help.

I tried to put it in the way the insert formatted MQL4 Code said to but the file was too long.

double Gann = iCustom(NULL, 0, "###Gann_HiLo_Activator_v2###", True, 0, Current + 0);
double Gann1 = iCustom(NULL, 0, "###Gann_HiLo_Activator_v2###", True, 0, Current + 1);


double FastMain = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Strong Trend Line *** *** Indicator Settings ***", True, 2, Current + 0);
double FastSignal = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Weak Trend Line *** *** Indicator Settings ***", True, 3, Current + 0);

double FastMain1 = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Strong Trend Line *** *** Indicator Settings ***", True, 2, Current + 1);
double FastSignal1 = iCustom(NULL, 0, "AbsoluteStrenghtHisto_v2", "*** Weak Trend Line *** *** Indicator Settings ***", True, 3, Current + 1);  
   
   
   //+------------------------------------------------------------------+
   //| Variable End                                                     |
   //+------------------------------------------------------------------+

   //Check position
bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
            //Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Buy)                                           |
            //+------------------------------------------------------------------+

if (PRICE_OPEN < Gann) Order = SIGNAL_CLOSEBUY;
if (FastMain < FastSignal)Order = SIGNAL_CLOSESELL;

            //+------------------------------------------------------------------+
            //| Signal End(Exit Buy)                                             |
            //+------------------------------------------------------------------+

            if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
               if (!EachTickMode) BarCount = Bars;
               IsTrade = False;
               continue;
            }
            //MoveOnce
            if(MoveStopOnce && MoveStopWhenPrice > 0) {
               if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) {
                  if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) {
                  OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
The whole program was too long so this portion should show what I tried to do but it does not work.

This is what I used for my entry. Since I have to do it in pieces. I have no compiling errors but my entry and exit are not what I am trying to accomplish.

   //+------------------------------------------------------------------+
   //| Signal Begin(Entry)                                              |
   //+------------------------------------------------------------------+
   
if ((PRICE_OPEN > Gann)&& (FastMain > FastSignal)) Order = SIGNAL_BUY;
if ((PRICE_OPEN < Gann)&& (FastMain < FastSignal)) Order = SIGNAL_SELL;

   //+------------------------------------------------------------------+
   //| Signal End                                                       |
   //+------------------------------------------------------------------+

   //Buy
   if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
      if(!IsTrade) {
         //Check free margin
         if (AccountFreeMargin() < (1000 * Lots)) {
            Print("We have no money. Free Margin = ", AccountFreeMargin());
            return(0);
         }

         if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
         if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

         Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
         if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
                Print("BUY order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
            } else {
                Print("Error opening BUY order : ", GetLastError());
            }
         }
         if (EachTickMode) TickCheck = True;
         if (!EachTickMode) BarCount = Bars;
         return(0);
      }
   }

I do not even know what to ask for help with since the program is not working the way I intended it to work. It exits when it should be holding the entries and I have no clue why it keeps taking new entry orders because I do not know why it got out in the first place. Running on the one hour charts I got 5 entry and exit and re entry orders when according to my parameters it should have simply held the position. This was on the GBP/JPY. With the spread being so high I lost money on what shold have been a winning position. I would like to get a knowledgeable programmer to look at it and see if they could help me fix it. I really do not know what to post or even the right question to ask. I can guess that it is in my exit coding. This is a fairly simlple program as it should enter long (Buy) when price opens over the testing level of the Gann HiLo Activator indicaor && Buffer 2 of the AbsoluteStenghtHisto > Buffer 3 of the AbsoluteStrnghtHisto.

It shold hold the trade until either of these parameters is no longer true. Then if they become true again it should re enter the position.

The reverse is the parameters for the Sell.