Gilgameash
New member
good tool to have, if you don't want to keep position open over the weekends. got tired of huge weekend losses.
WIP
WIP
Rich (BB code):
# close out every friday
input Plot_Is_It_Friday= yes;
input Plot_Is_It_Friday_Exit= yes;
# close on second to last bar on fridays
def timeFrame = GetAggregationPeriod();
def EOD = if timeFrame ==
AggregationPeriod.MIN and SecondsTillTime(1557) == 0 then 1 else if timeFrame ==
AggregationPeriod.TWO_MIN and SecondsTillTime(1554) == 0 then 1 else if timeFrame ==
AggregationPeriod.THREE_MIN and SecondsTillTime(1551) == 0 then 1 else if timeFrame ==
AggregationPeriod.FOUR_MIN and SecondsTillTime(1550) == 0 then 1 else if timeFrame ==
AggregationPeriod.FIVE_MIN and SecondsTillTime(1545) == 0 then 1 else if timeFrame ==
AggregationPeriod.TEN_MIN and SecondsTillTime(1530) == 0 then 1 else if timeFrame ==
AggregationPeriod.FIFTEEN_MIN and SecondsTillTime(1515) == 0 then 1 else if timeFrame ==
AggregationPeriod.TWENTY_MIN and SecondsTillTime(1510) == 0 then 1 else if timeFrame ==
AggregationPeriod.THIRTY_MIN and SecondsTillTime(1430) == 0 then 1 else 0;
def Exit_Time= EOD;
#is it friday?
def isFriday = GetDayOfWeek(GetYYYYMMDD()) == 5;
def allFridays = GetDayOfWeek(GetYYYYMMDD()[1]) == 5 ;
plot Friday_baby = if isFriday and Plot_Is_It_Friday then 1 else 0;
plot Friday_baby_Exit = if isFriday and Plot_Is_It_Friday_Exit and Exit_Time then 1 else 0;
Friday_baby.SetPaintingStrategy(paintingStrategy = PaintingStrategy.DASHES);
Friday_baby_Exit.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_UP);
addOrder(OrderType.SELL_TO_CLOSE,Friday_baby_Exit, tickColor = Color.GREEN, arrowColor = Color.GREEN, name = "Friday Long Close");
AddOrder(type = OrderType.BUY_TO_CLOSE, condition = Friday_baby_Exit, arrowColor = Color.RED, name = "Friday Short Close", tickColor = Color.RED);