A Free Trading System In Development

 

Hello,

Trading is hard.

Why trade? To make money. 

How to trade? Buy low, sell high.

This is essentially the gist of it, right?

To decide whether I want to Buy or Sell I first need a Bias.  I figured I'd take the Open Price as my starting point and set a target on previous highs if my bias is Bullish and the previous lows if my bias is Bearish.  I put together this indicator called Levels (attached) and it draws a line from the Open into the future to the previous highs, if My Bias is Bullish for the selected period. (only one duration and one direction can be chosen)

Now, to decide what is a dip I used the following logic - price goes from open to previous highs, but can retrace all the way to the previous lows and if it breaks them it will start to reverse the trend, right?  So, I draw the so-called Baseline from Open to previous High, and the so-called Anchor from previous Low at the time of Open and parallel to Baseline until the end of the selected duration. 

levelsexample

...kind of like this, this is an hourly chart, TimePeriod: Weekly, My Bias: Bullish.

As you can see, the Baseline (green line above) start at the current Week's Open time and Price and goes into the future towards the previous Week's High and the Anchor (green line below) starts at the current Week's Open time as well and previous Week Low, it then extends parallel to Baseline until week end.  What I do next is fairly logical, I take the width of this Baseline-to-Anchor channel, divide it in quarters and called the resulting lines: extensions, retracements, and reversals.

Now, I want to place a Buy order if price gets close to any of these lines.  So, for example, in the image above price is near the first retracement, so I send a Buy order on the line, and since price is below it, the order shall be an OP_BUYSTOP.  And my LevelBracketsEA (attached) does so every time price approaches any of these lines and goes into an Entry Bracket.  The size of the Entry Bracket can be set at your discretion, and even though it is possible to make it dynamic, I'm sticking to a fixed size bracket for now, simply because I didn't figure out how to do that in a way to not worry too much that the system is getting slowed down too hard.  Anyway, so price gets into a bracket, pending order is placed and until it gets filled it is modified to trace the slope of the respective line and when price leaves the bracket and the order remains unfilled, it's deleted.  If however the order got filled a static stop loss and take profit have been assigned to it and the line itself is now with an order so duplicate orders aren't opened on it...also, the stops and takes aren't being modified once the Pending order gets filled and perhaps I should consider that later when I get to worrying about checking account balance, available margin, cumulative risk exposure and such, then perhaps I could/should trace the stops, do moves to break-even, take partial profits, etc. is the way this story goes, logically.

So, now I think I got really close to the first reason I'm posting ...as you can see in the source as well,

//------------------------------------------find Bracket of Line, Place or Modify the right Pending Order on the vM-----   
      if(Bid<=vM && Bid>=LB && Bid<= UB){
               if(OrderFind(MagicBulls[i]) == false){          //&& (BuyFilters(Symbol,Period) == true)
                  if(OrderSend(ChartSymbol(),OP_BUYSTOP,PositionSize,vM,3,sl,tp,"",MagicBulls[i],0,clrNONE) < 0)
                  Print("Err (",GetLastError(), ") Open BuyStop at Price= ", vM, " SL= ",sl," TP= ", tp);
               else if(OrderFind(MagicBulls[i] == true) && glbOrderType == OP_BUYSTOP){
                  if(vM != OrderOpenPrice())
                     if(OrderModify(glbOrderTicket,vM,sl,tp,0,clrNONE) == false)
                     Print("Err (",GetLastError(), ") Modify BuyStop Price= ",vM," SL= ",sl," TP= ",tp);
                     }}}   
      if(Bid>=vM && Bid>= LB && Bid <=UB){
               if(OrderFind(MagicBulls[i]) == false)
                  if(OrderSend(ChartSymbol(),OP_BUYLIMIT, PositionSize,vM,3,sl,tp,"",MagicBulls[i],0,clrNONE)<0) 
                  Print("Err (",GetLastError(), ") Open BuyLimit at Price= ",vM, " SL= ",sl," TP= ",tp);
               else if(OrderFind(MagicBulls[i]) == true && glbOrderType == OP_BUYLIMIT){
                  if(vM != OrderOpenPrice())
                     if(OrderModify(glbOrderType,vM,sl,tp,0,clrNONE) == false)
                     Print("Err (",GetLastError(), ") Modify BuyLimit Price=",vM, "SL= ",sl," TP= ",tp);
                     }}}

the way I'm checking if the Price is inside the bracket is by if-ing the relative position of Bid to the Lower and Upper bounds of the bracket (LB & UB) and the line itself (vM) and the thing is that I'm thinking how to add a filter and should I?  The way I imagine the filter would work is by the following formula: MathAbs(Σfilters - my bias * number_of_filters)<=(number_of_filters divide by 2)...this way, when my bias is either 0 for Buy or 1 for Sell and my filters are also either 0 or 1 (for buy or sell) I'd be getting the following...

...say I want to use 4 filters: RSI, MACD, Stochastic, and an MA cross, and the way to set it up is like this

1) RSI crosses from below 20, above 20;
2) MACD crosses from below 0 to above 0,
3) Stochastic signal line crosses above the main line;
4) shorter MA crosses longer MA from above

I'd be getting 1) RSI filter =0, 2)MACD filter = 0, 3) Stochastic =0; 4) MA cross filter =1 (remember? 0 is Buy, 1 is Sell, my bias is Sell) then I have MathAbs((0+0+0+1)-1*4)<=4/2 which is false and so my filters won't be confirming entry

If, however I had 5 filters in a sell bias and 3 of them gave me sell confirmations, while two gave me buys, I'd have 1+1+1+0+0=3, minus 1*5, equals negative 2, MathAbs equals 2; number of filters divided by 2 equals 2.5 and it's greater than...so Sell is confirmed.  Of course, the filtering logic could be adjusted to justify a fancy name for the EA, like for example the Slow Burner or the Fury Blast, whatever...such names not only don't fit with this type of trading logic but, also aren't good associations for the above mentioned filters either, in my humble opinion. 

More importantly, what do you think of the way I'm running the price checks for order placement?  And two, how should I go about implementing a BuyFilters check...I'm thinking of a bool that would return true or false after calculating all the indicator filters and running them through the formula to compare to the bias, so I'd have a BuyFilters(Symbol(),period) == 0 means that the filters confirm a Buy in the given period for the given symbol.   What would you recommend I look at to get additional clues.   Additionally, how would you recommend I improve this code?

PS. place indicator, add EA (Levels indicator is Current time-frame by default and it uses OnChartEvent() so changing time-frame back and forth helps if you see nothing at first...also, I'm using OnChartEvent() because I want the EA to see the lines)

Files:
 

small addition...

the way I imagine the filters would work is default setting is opposite of the bias, so if its a BuyFilter everything is set to a flagval=1, then I check the previous 4 or 5 iterations and if a signal happens I change the flagval to 0 and if not, it stays at 1, same with SellFilter (0-to-1).  So...price gets inside the bracket and the filters run and if they confirm an OrderSend then it happens.  What do you think of the computational lag, speed, how long it will take to calculate, am I going to be missing out a lot, and of course, any advice about what I should look at?  I'm also thinking about turning to/learning something new about oop-ing this, maybe using something of the #include nature, making some kind of library of ...classes, methods, whatever, I know almost nothing about it, but want to learn, could you recommend something other than a book? 

Thank You.

 
Alex Go:

small addition...

the way I imagine the filters would work is default setting is opposite of the bias, so if its a BuyFilter everything is set to a flagval=1, then I check the previous 4 or 5 iterations and if a signal happens I change the flagval to 0 and if not, it stays at 1, same with SellFilter (0-to-1).  So...price gets inside the bracket and the filters run and if they confirm an OrderSend then it happens.  What do you think of the computational lag, speed, how long it will take to calculate, am I going to be missing out a lot, and of course, any advice about what I should look at?  I'm also thinking about turning to/learning something new about oop-ing this, maybe using something of the #include nature, making some kind of library of ...classes, methods, whatever, I know almost nothing about it, but want to learn, could you recommend something other than a book? 

Thank You.

it's quite clear why people trade...whether it's Forex, stocks, bond indices or something else it's to make money, what would the purpose else be...

What's wrong with a book? are you to lazy to read perhaps...

 
Kenneth Parling:

it's quite clear why people trade...whether it's Forex, stocks, bond indices or something else it's to make money, what would the purpose else be...

What's wrong with a book? are you to lazy to read perhaps...

Not at all, do you have a good recommendation? My wording was simply meant to emphasize specificity.  Trading and Exchanges. Market microstructure for practitioners - is a good one. Which one were you going to recommend?
 
this is an additional component and it's about bias selection ...I'll post it as a separate question called Pivot Preference
Reason: