Created
March 30, 2020 19:35
-
-
Save ApopheniaPays/0ffc3a08736c4c4769e920ef47fb8ff2 to your computer and use it in GitHub Desktop.
ApopheniaPays Range Strategy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ | |
// © ApopheniaPays | |
//@version=4 | |
strategy("ApopheniaPays Range Strategy",overlay=true) | |
buySource=input(low,"Buy when this cross buy price") | |
sellSource=input(high,"Buy when this cross sell price") | |
crossValue=input(5881.0,"Price to buy at") | |
sellValue=input(5944.0,"Price to sell at") | |
FromDate=input(032920,title="From MMDDYY",minval=010100,maxval=123199 ) | |
FromTime=input(1100,"From HHMM (24 hr time)",minval=0,maxval=2359) | |
FromMonth=floor(FromDate/10000) | |
FromDay=floor((FromDate%10000)/100) | |
FromYear=floor(FromDate%100)+2000 | |
FromHour=floor(FromTime/100) | |
FromMin=floor(FromTime%100) | |
ToDate=input(123120,title="To MMDDYY",minval=010100,maxval=123199 ) | |
ToTime=input(1107,"To HHMM (24 hr time)",minval=0,maxval=2359) | |
ToMonth=floor(ToDate/10000) | |
ToDay=floor((ToDate%10000)/100) | |
ToYear=floor(ToDate%100)+2000 | |
ToHour=floor(ToTime/100) | |
ToMin=floor(ToTime%100) | |
timeZone=input("GMT-8","Time zone for above in GMT +/- notation") | |
okToGo=(time>= timestamp(timeZone,FromYear, FromMonth, FromDay, FromHour, FromMin)) and (time<= timestamp(timeZone,ToYear, ToMonth, ToDay, ToHour, ToMin)) | |
var theCount=0 | |
//"crossing over","crossing under","both","any touch" | |
crossing=(crossover(buySource,crossValue) and okToGo) | |
crossingSell=(crossover(sellSource,sellValue) and okToGo) | |
strategy.entry("long",true,when=(crossing and okToGo)) | |
strategy.close("long",when=(crossingSell and okToGo)) | |
plot(okToGo?crossValue:na,"buy price",color=color.green,transp=0) | |
plot(okToGo?sellValue:na,"sell price",color=color.red,transp=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pine script range strategy by request.