Here I have got the code so far. My Problem is that it sells also intraday but it should sell on a daily-basis. E.g. after 5 full days. How can I calculate this?
/* How can I calculate something on a DailyBar-Chart and use this Information on the intradayChart of one specifc day? Here is my Idea: 1.QUESTION I will calculate a MA: if Close>MA on a DailyBar. If this is true Then the code should Buy intraDay on the basis of the Close>MA from the DailyBar the Day before a specific %-amount under yesterdays Close. If this is true then I the code should BUY on time per day. At the moment I calculate the MA on the Daily-basis with: TimeFrameSet(inDaily); .... TimeFrameRestore(); Is there a faster way to calculate this? 2.QUESTION If I have got a Position I will close this position with a timestop. I will go out after 1,2..x days. How can I count how long I'm in that position and geht the signal to close out? */ //Daily-Bar Calculation of the MA TimeFrameSet(inDaily); MA_UP_Daily = Close > MA(C,20) ; TimeFrameRestore(); //Make DailyBar value useable intrday MA_UP_Daily_from_DailyBar = TimeFrameExpand( MA_UP_Daily, inDaily); //If on the DailyBar MA>Close then Buy IntraDay 1% under the Close of Yesterday LimitUnderCloseYesterday = 0.01; yesterdayClose = TimeFrameGetPrice( "Close", inDaily, -1 ) ; //Calcualte LimitBuyPoint that means a Price 1% under yesterdays Close. LimitBuyPoint = yesterdayClose - yesterdayClose * LimitUnderCloseYesterday; Limitprice_Under_IntraDay_Low = Low < LimitBuyPoint ; //Check Buy Condition LONG_Signal = MA_UP_Daily_from_DailyBar AND Limitprice_Under_IntraDay_Low; //Buy actually Buy = LONG_Signal; //If a position is existing then sell after X DAYS. E.g. X=10 //H E R E I S T H E Q U E S T I O N //IT SELLS INTRADY. HAS ANYONE GOT AN IDEA WHO TO WRITE THIS TO SELL AFTER X DAYS????? TimeFrameSet(inDaily); Sell=0; ApplyStop( stopTypeNBar, stopModeBars, 10 ); TimeFrameRestore(); //Only the avoid failure-alert if "Long and Short" is select in the settings. Short=Cover=0;
